#!/usr/bin/env ./jshost


var time=function(f){
	var res, i, t1, t2;
	t1=new Date();
	f();
	t2=new Date();
	return t2 - t1;
};


var test1=function(n){
	var cnt1=0,cnt2=0;
	var rec=function(n, f){
//		alert("rec, n="+n+", cnt1="+cnt1+", cnt2="+cnt2);
		++cnt1;
		if(--n>0)
			setTimeout(function(){rec(n-1, f)}, 1);
		else
			f();
		++cnt2;
	}
	var t1=new Date();
	rec(n, function(){
		var t2=new Date();
		alert( "time="+(t2-t1) )
	});
};

test1(200);

sleep(1000*1000);


//time(function(){test1(1000)});

